package com.sh.test;


import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        Long max = Long.parseLong(str);
        String cur = str;
        for (int i =0; i<str.length(); i++){
            cur = cur.charAt(cur.length()-1) + cur.substring(0, cur.length()-1);
            max = Math.max(Integer.parseInt(cur), max);
        }
        System.out.println(max);
    }
}